<?php
if (!defined('DP_BASE_DIR')) {
	die('You should not access this file directly.');
}

require_once "Auth/OpenID/Consumer.php";
require_once "Auth/OpenID/FileStore.php";
require_once "Auth/OpenID/SReg.php";

// start session (needed for YADIS)
session_start();

// create file storage area for OpenID data
$store = new Auth_OpenID_FileStore('./oid_store');

// create OpenID consumer
// read response from OpenID provider
$consumer = new Auth_OpenID_Consumer($store);
$response = $consumer->complete('http://localhost/t/dotproject/modules/auth/complete.php');


// set session variable depending on authentication result
if ($response->status == Auth_OpenID_SUCCESS) {
  $_SESSION['OPENID_AUTH'] = true;
    var_dump($response);
  // get registration information
  $sreg = new Auth_OpenID_SRegResponse();
  $obj = $sreg->fromSuccessResponse($response);
  $data = $obj->contents(); 
  var_dump($data);



} else {
  $_SESSION['OPENID_AUTH'] = false;    
}

// redirect to restricted application page
header('Location: restricted.php');  
?>
